<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/admin/include/init_admin.jsp" %>
<%@ page import="com.joinhawaii.admin.sales.*" %>
<%


	String job_type		= "U";
	String req_id		= StringUtil.nvl(request.getParameter("req_id"));
	String est_no		= StringUtil.nvl(request.getParameter("est_no"));
	String est_type		= "1";

	if (est_no.equals("")) {
		job_type = "C";
	}


	HashMap infos = new HashMap();
	infos.put("est_no",	est_no);
	infos.put("req_id", req_id);
	infos.put("est_type", est_type);

	SalesDAO dao 			= new SalesDAO();


	HashList list 			= dao.selectReqInfo(infos);		//견적의뢰
	HashList estList 		= dao.selectEstList(infos);		//견적서 목록




	String s_req_dt			= StringUtil.nvl(request.getParameter("s_req_dt"));
	String s_start_dt_from	= StringUtil.nvl(request.getParameter("s_start_dt_from"));
	String s_start_dt_to	= StringUtil.nvl(request.getParameter("s_start_dt_to"));
	String s_req_status		= StringUtil.nvl(request.getParameter("s_req_status"));
	String s_customer_name	= StringUtil.toHan(request.getParameter("s_customer_name"));
	String s_email_addr		= StringUtil.toHan(request.getParameter("s_email_addr"));
	String s_phone_no		= StringUtil.nvl(request.getParameter("s_phone_no"));
	String s_hotel_name		= StringUtil.nvl(request.getParameter("s_hotel_name"));
	String s_enjoy_name		= StringUtil.nvl(request.getParameter("s_enjoy_name"));
	String s_car_company	= StringUtil.nvl(request.getParameter("s_car_company"));

	String s_hotel_chk		= StringUtil.nvl(request.getParameter("s_hotel_chk"));
	String s_enjoy_chk		= StringUtil.nvl(request.getParameter("s_enjoy_chk"));
	String s_car_chk		= StringUtil.nvl(request.getParameter("s_car_chk"));

	String s_curr_page		= StringUtil.nvl(request.getParameter("s_curr_page"),"1");



	String where = "?1=1";
	if (!"".equals(s_req_dt))			where += "&s_req_dt=" + s_req_dt;
	if (!"".equals(s_start_dt_from))	where += "&s_start_dt_from=" + s_start_dt_from;
	if (!"".equals(s_start_dt_to))		where += "&s_start_dt_to=" + s_start_dt_to;
	if (!"".equals(s_req_status))		where += "&s_req_status=" + s_req_status;
	if (!"".equals(s_customer_name))	where += "&s_customer_name=" + s_customer_name;
	if (!"".equals(s_email_addr))		where += "&s_email_addr=" + s_email_addr;
	if (!"".equals(s_phone_no))			where += "&s_phone_no=" + s_phone_no;
	if (!"".equals(s_hotel_name))		where += "&s_hotel_name=" + s_hotel_name;
	if (!"".equals(s_enjoy_name))		where += "&s_enjoy_name=" + s_enjoy_name;
	if (!"".equals(s_car_company))		where += "&s_car_company=" + s_car_company;
	if (!"".equals(s_hotel_chk))		where += "&s_hotel_chk=" + s_hotel_chk;
	if (!"".equals(s_enjoy_chk))		where += "&s_enjoy_chk=" + s_enjoy_chk;
	if (!"".equals(s_car_chk))			where += "&s_car_chk=" + s_car_chk;



%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>조인하와이</title>
	<%@ include file="/admin/include/cssnjs.jsp"  %>

	<script type="text/javascript">

	$(document).ready(function() {
	<%	if (!"".equals(est_no)) {	%>
		fnEstDetail('<%= est_no %>');
	<%	}	%>
	});

	// 견적서 보기
	function fnEstDetail(est_no) {
		$('#est_detail').html('');
		$('#est_detail').load('./estForm.jsp?req_id=<%=req_id%>&est_no='+est_no, '', function() {
			$('#issue_dt').mask('9999.99.99').datepicker();
			$('#travel_start_dt').mask('9999.99.99').datepicker();
			$('#travel_end_dt').mask('9999.99.99').datepicker();
		});
	}

	// 저장, 신규, 삭제
	function fnEstSave(jobType) {
		if (cfCheckNull(document.estSaveForm.title, "제목을 입력해주세요"))	return false;
		if (confirm(MSG_SAVE)) {
			$('#estSaveForm input[name="job_type"]').val(jobType);
			$('#estSaveForm').attr('action', './estSave.do');
			$('#estSaveForm').submit();
		}
	}

	// 예약확인
	function fnReserve() {
		if (confirm(MSG_SAVE)) {
			$('#estSaveForm input[name="est_type"]').val("2");
			$('#estSaveForm').attr('action', './estReserve.do');
			$('#estSaveForm').submit();
		}
	}


	function fnEstPrint(est_no) {
		cfOpen('/home/voucher/masterVoucher.jsp?est_no='+est_no, '조인하와이', 900, 600);
	}

	</script>
</head>
<body>
<div id="wrap">
	<div id="top">
		<%@ include file="/admin/include/top.jsp" %>
	</div>
	<div id="page">
		<div id="menu">
			<%@ include file="/admin/include/leftMenu.jsp" %>
		</div>
		<div id="contents">
			<div class="menu_title">
				<h1>견적의뢰</h1>
				<p>관리자 > 견적관리 > <b>견적의뢰</b></p>
			</div>
			<div class="clear line_01"></div>



			<ul id="tabs" class="tab_01 mt15">
			    <a href="./reqDetail.jsp?req_id=<%= req_id %>"><li class="off"  code="1"><p>1. <%= "2".equals(list.get("req_gubn",0)) ? "바로예약" : "견적의뢰" %></p></li></a>
			    <li class="on"  code="2"><p>2. 견적서</p></li>
			    <a href="./confirmDetail.jsp?req_id=<%=req_id %>"><li class="off"  code="3"><p>3. 예약확인서</p></li></a>
			</ul>



			<div id="tabs-2" class=" mt15">



				<table width="100%" cellpadding="0" cellspacing="0" class="table_04 mt15">
				<colgroup>
					<col width="100px" />
					<col  />
					<col width="100px" />
					<col width="100px" />
					<col width="100px" />
					<col width="100px" />
				</colgroup>
				<tr>
					<th><p>견적번호</p></th>
					<th><p>제목</p></th>
					<th><p>출발일</p></th>
					<th><p>상태</p></th>
					<th><p>최종수정자</p></th>
					<th><p>최종수정일</p></th>
				</tr>
			<% 	for (int i = 0; i < estList.size(); i++) {	%>
				<tr>
					<td><a href="#nohref" onclick="fnEstDetail('<%= estList.get("est_no", i) %>')"><%= estList.get("est_no", i) %></a></td>
					<td><a href="#nohref" onclick="fnEstDetail('<%= estList.get("est_no", i) %>')"><%= estList.get("title", i) %></a></td>
					<td><%= StringUtil.toDate(estList.get("travel_start_dt", i)) %></td>
					<td><%= estList.get("est_state_name", i) %></td>
					<td><%= estList.get("up_user", i) %></td>
					<td><%= estList.get("up_date", i) %></td>
				</tr>

			<%	} %>
				</table>


				<div class="mt20 mb10 c">
					<a href="./reqList.jsp<%=where%>"><img src="/images/admin/btn_list.gif"/></a>
					<a href="#nohref" onclick="fnEstDetail('')"><img src="/images/admin/btn_new.gif"  /></a>
				</div>


				<div id="est_detail" class="mt30">

				</div>

			</div>





		</div>
	</div>
</div>

</body>
</html>
